package com.aaa.repast.app.wx.cartItem.controller;

import java.util.List;
import com.aaa.repast.app.web.controller.BaseController;
import com.aaa.repast.app.web.domain.AjaxResult;
import com.aaa.repast.app.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.aaa.repast.app.wx.cartItem.domain.CartItem;
import com.aaa.repast.app.wx.cartItem.service.ICartItemService;

/**
 * 购物车 信息操作处理
 * 
 * @author teacherChen
 * @date 2019-12-30
 */
@RestController
@RequestMapping("/wx/cartItem")
@Api(tags = "购物车信息操作处理接口")
public class CartItemController extends BaseController
{
	@Autowired
	private ICartItemService cartItemService;
	/**
	 * 查询购物车列表
	 */
    @ApiOperation(value = "查询购物车列表")
    @ApiImplicitParam(name = "查询参数",value = "查询参数",dataTypeClass = CartItem.class)
	@PostMapping("/list")
	public TableDataInfo list(CartItem cartItem)
	{
		startPage();
        List<CartItem> list = cartItemService.selectCartItemList(cartItem);
		return getDataTable(list);
	}
	
	

	

	/**
	 * 新增保存购物车
	 */
    @ApiOperation(value = "新增保存购物车")
    @ApiImplicitParam(name = "参数",value = "参数",dataTypeClass = CartItem.class)
	@PostMapping("/add")
	public AjaxResult addSave(CartItem cartItem)
	{		
		return toAjax(cartItemService.insertCartItem(cartItem));
	}


	/**
	 * 修改保存购物车
	 */
    @ApiOperation(value = "修改保存购物车")
    @ApiImplicitParam(name = "参数",value = "参数",dataTypeClass = CartItem.class)
	@PostMapping("/edit")
	public AjaxResult editSave(CartItem cartItem)
	{		
		return toAjax(cartItemService.updateCartItem(cartItem));
	}
	
	/**
	 * 删除购物车
	 */
    @ApiOperation(value = "删除购物车")
    @ApiImplicitParam(name = "参数",value = "参数",dataTypeClass = String.class)
	@PostMapping( "/remove")
	public AjaxResult remove(String ids)
	{		
		return toAjax(cartItemService.deleteCartItemByIds(ids));
	}
	
}
